<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<title>管理员登录</title>
<link th:href="@{/css/login.css}" rel="stylesheet"/>
<body>
<div class="auth-container">

    <div th:if="${errorMsg!=null}" class="form-container">
        <h1 th:text="${errorMsg}"></h1>
        <h2>3秒后进入<a href="/admin/helloAdmin">登录页面</a></h2>
    </div>

    <div th:if="${errorMsg == null}" class="form-container">
        <h2>管理员账号登录</h2>
        <form action="/admin/login" method="POST">
            <label for="adminusername">用户名</label>
            <input type="text" id="adminusername" name="adminusername" required placeholder="请输入您的用户名">

            <label for="adminpassword">密码</label>
            <input type="password" id="adminpassword" name="adminpassword" required placeholder="请输入您的密码">

            <label for="captcha">验证码：</label>
            <input type="text" id="captcha" name="captcha" required>
            <img th:src="@{/captcha}" alt="验证码" onclick="this.src='/captcha?d=' + Math.random()">

            <button type="submit" class="btn">登录</button>
        </form>
    </div>
</div>
</body>
<script th:inline="javascript" th:if="${errorMsg!= null}">
    setTimeout(function () {
        window.location.href = "/admin/helloAdmin";
    }, 3000);
</script>
</html>
